package org.hot100_5.leetcode46;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    //不含重复数字的全排列

    List<List<Integer>> res = new ArrayList<>();
    List<Integer> item = new ArrayList<>();
    public List<List<Integer>> permute(int[] nums) {
        backtracking(nums);
        return res;
    }

    private void backtracking(int [] nums){
        if (item.size()==nums.length){
            res.add(new ArrayList<>(item));
            return;
        }

        for (int i = 0; i < nums.length; i++) {
            if (item.contains(nums[i])){
                continue;
            }

            item.add(nums[i]);
            backtracking(nums);
            item.remove(item.size()-1);
        }
    }

}
